#include "downloadui.h"
#include "ui_downloadui.h"
#include "mysettings.h"
#include <QLabel>
#include "download.h"

DownloadUI::DownloadUI(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::DownloadUI)
{
    ui->setupUi(this);
}

void DownloadUI::insertWidget(QWidget *w)
{
    ui->vLayout->insertWidget(0,w);
}

void DownloadUI::setAccessManager(myNetworkAccessManager *manager)
{
    m_accessManager = manager;
}

void DownloadUI::downloadFile(const QUrl &url)
{
    Download* download = new Download(this);
    if(download->savePath(url))
    {
        download->setAccessManager(m_accessManager);
        download->DownloadFile();
        ui->vLayout->insertWidget(0,download);
        show();
    }
}

DownloadUI::~DownloadUI()
{
    delete ui;
}
